namespace SimpleWebServices.Models
{
    using System;
    using SimpleWebServices;
    using SimpleWebServices.Data;
    using SimpleWebServices.Web.Mvc;
    using Xunit;

    public sealed class SubmissionDebugFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<SubmissionDebug>()
                .DerivesFrom<object>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Implements<IProcessSubmission>()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new SubmissionDebug());
        }

        [Fact]
        public void op_Process_FormSubmission()
        {
            Token token = Token.New();

            FormSubmission submission = new FormSubmission
            {
                Token = token
            };

            SeeOtherResult result = new SubmissionDebug().Process(submission) as SeeOtherResult;

            Assert.Equal<string>("/debug/submission?" + token, result.Location);
        }

        [Fact]
        public void op_Process_FormSubmissionNull()
        {
            Assert.Throws<ArgumentNullException>(() => new SubmissionDebug().Process(null as FormSubmission));
        }

        [Fact]
        public void op_Process_FormSubmission_whenTokenMissing()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new SubmissionDebug().Process(new FormSubmission()));
        }
    }
}